package com.cmcc.xdr.message;

import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.cmcc.xdr.entity.BiccEntity;
import com.cmcc.xdr.util.TBCDUtil;

public class SingleSigBiccMsg extends SingleSigMsg {

	public BiccEntity nc = new BiccEntity();
	private static SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

	public SingleSigBiccMsg(ByteBuffer buffer,SingleSigGlobalMsg globalMsg) {
		this.setBuffer(buffer);
		this.setSSGMsg(globalMsg);

		nc.setLength(globalMsg.getTotalLength());
		nc.setLocalProvince(globalMsg.getLocalProvince());
		nc.setLocalCity(globalMsg.getLocalCity());
		nc.setOwnerProvince(globalMsg.getOwnerProvince());
		nc.setOwnerCity(globalMsg.getOwnerCity());
		nc.setRoamingType(globalMsg.getRoamingType());
		nc.setInterFace(globalMsg.getInterfaceType());
		nc.setXdrId(globalMsg.getXdrID());
		nc.setRat(globalMsg.getRat());
		nc.setImsi(globalMsg.getImsi());
		nc.setImei(globalMsg.getImei());
		nc.setMsisdn(globalMsg.getMsisdn());

		nc.setbTime(new Date(loadLong(8)));   //开始时间
		nc.seteTime(new Date(loadLong(8)));   //结束时间
		nc.setProtocolId(loadInt(2));   //  协议
		nc.setSpckind(loadInt(1));   // 编码类别
		nc.setOpc(loadInt(4));   // 源信令点
		nc.setDpc(loadInt(4));   // 目的信令点
		nc.setPcm(loadInt(4));   // pcm线
		nc.setCic(loadInt(1));   // 时隙号
		nc.setSls(loadInt(1));   // 信令链路选择码
		nc.setCallingNum(TBCDUtil.toTBCD(loadByte(26)));   // 主叫号码
		nc.setCalledNum(TBCDUtil.toTBCD(loadByte(26)));   //  被叫号码
		nc.setoCalledNum(TBCDUtil.toTBCD(loadByte(26)));   // 原被叫号码
		nc.setRecalledNum(TBCDUtil.toTBCD(loadByte(26)));   //改发号码
		nc.setMsrn(TBCDUtil.toTBCD(loadByte(26)));   //   漫游号码
		nc.setCallingNumNature(loadInt(1));   //主叫号码属性 
		nc.setCalledNumNature(loadInt(1));   // 被叫号码属性
		nc.setOcalledNumNature(loadInt(1));   //原被叫号码属性
		nc.setRecalledNumNature(loadInt(1));   //   改发号码属性
		nc.setCalledStatus(loadInt(1));   //被叫状态
		nc.setCallTrans(loadInt(1));   //   呼叫转移
		nc.setCallTransType(loadInt(1));   //   呼转类型
		nc.setChargeind(loadInt(1));   //   计费指示 
		nc.setEventId(loadInt(1));   // 事件类型
		nc.setEventCause(loadInt(4));   //  释放原因
		nc.setEventResult(loadInt(1));   // 事件结果
		nc.setSeizureDur(loadInt(4));   //  占用时长
		nc.setAnswerDur(loadInt(4));   //   通话时长
		nc.setAcmOffset(loadInt(4));   //   地址全时间
		nc.setAnmOffset(loadInt(4));   //   应答时间
		nc.setRelOffset(loadInt(4));   //   释放时间
		nc.setRlcOffset(loadInt(4));   //   释放完成时间
		nc.setSaoOffset(loadInt(4));   //   最后一条前向消息时间
		nc.setAnsOffset(loadInt(4));   //   第一条后向消息时间
		nc.setProcess1(loadInt(4));   //消息出现1
		nc.setProcess2(loadInt(4));   //消息出现2
		nc.setProcess3(loadInt(4));   //消息出现3
		nc.setDirection1(loadInt(4));   //  消息方向1
		nc.setDirection2(loadInt(4));   //  消息方向2
		nc.setDirection3(loadInt(4));   //  消息方向3
		nc.setXdrType(loadInt(1));   // XDR类型
		nc.setBearType(loadInt(1));   //承载类型
		nc.setoAddresss(loadLong(8));   //  承载地址（发起）
		nc.setdAddresss(loadLong(8));   //  承载地址（结束）
		nc.setCdrId(loadLong(8));   //  cdrid
		nc.setSessionId(loadLong(8));   //  sessionid
		nc.setGlobalId(loadLong(8));   //   globalid

		nc.setInsertDate(format.format(new Date()));
	}

	public BiccEntity getNc() {
		return nc;
	}

	public void setNc(BiccEntity nc) {
		this.nc = nc;
	}


}